#ifndef GX_FR_GLOBAL_H
#define GX_FR_GLOBAL_H

#include "Basic/GxLibBasic.h"
#include "Basic/Stream.h"
#include "Entity.h"

namespace FinalRendering
{
	namespace Engine
	{
		class FR_Global : public Object
		{
		private:
			struct PluginModule
			{
				HMODULE module;
				DestroyProc destroy;
			};
			String pluginLoadErrInfo;
			bool pluginLoadErr;
			String workDir;
			Array<PluginModule> modules;
			Mapping<String, IEntityDesc *> entityDescRegistry;
			void UnloadEntityPluginModules();
		public:
			FR_Global(bool isEditor);
			~FR_Global();
			String GetWorkingDirectory();
			void LoadEntityPlugins(bool isEditor);
			bool IsPluginLoadError();
			String GetPluginLoadErrorInfo();
			int GetEntityPluginCount();
			IEntityDesc * GetEntityDesc(int i);
			IEntityDesc * GetEntityDesc(const String & className);
		};

		extern RefPtr<FR_Global> Global;

		void CreateGlobal(bool isEditor);
		void DestroyGlobal();
	}
}
#endif